package kr.hkit.powerjava.chapter12.pro;

import java.util.Random;

class Shape {
	protected int x;
	protected int y;
	public void draw() {
		System.out.println("Shape Draw");
	}
}

class Rectangle extends Shape implements Movable {
	private int width;
	private int height;
	public void draw() {
		System.out.println("Rectangle Draw");
	}
	@Override
	public void move(int dx, int dy) {
		System.out.println("Rectangle> dx:" + dx + " dy:" + dy);
	}
}

class Triangle extends Shape implements Movable {
	private int base;
	private int height;
	public void draw() {
		System.out.println("Triangle Draw");
	}
	@Override
	public void move(int dx, int dy) {
		System.out.println("Triangle> dx:" + dx + " dy:" + dy);
	}
}

class Circle extends Shape implements Movable {
	private int radius;
	public void draw() {
		System.out.println("Circle Draw");
	}
	@Override
	public void move(int dx, int dy) {
		System.out.println("Circle> dx:" + dx + " dy:" + dy);
	}
}
public class MovableTest {
	private static Movable arrayOFMovables[];
	public static void main(String[] args) {	
		init();
		moveAll();
	}
	
		public static void init() {
			arrayOFMovables = new Movable[3];
			arrayOFMovables[0] = new Rectangle();
			arrayOFMovables[1] = new Triangle();
			arrayOFMovables[2] = new Circle();
		}
		
		public static void moveAll() {
			Random rnd = new Random();
			for(int i = 0; i < arrayOFMovables.length; i++) {
				arrayOFMovables[i].move(rnd.nextInt(10), rnd.nextInt(10));
		}
	}
}
